<template>
  <a-modal
    :visible="visible"
    title="编辑标段信息"
    cancelText="取消"
    okText="提交"
    @ok="submit"
    @cancel="cancel"
  >
    <a-form
      ref="formRef"
      :model="formState"
    >
      <a-form-item ref="name" label="标段名称" name="name">
        <a-input v-model:value="formState.name" />
      </a-form-item>
      <a-form-item ref="type" label="类型" name="type">
        <a-input v-model:value="formState.type" />
      </a-form-item>
      <a-form-item ref="zhaobdw" label="招标单位" name="zhaobdw">
        <a-input v-model:value="formState.zhaobdw" />
      </a-form-item>
      <a-form-item ref="dljg" label="招标代理机构" name="dljg">
        <a-input v-model:value="formState.dljg" />
      </a-form-item>
      <a-form-item ref="zbnr" label="招标内容" name="zbnr">
        <a-textarea v-model:value="formState.zbnr" />
      </a-form-item>
      <a-form-item ref="zbwj" label="招标文件" name="zbwj">
        <a-input v-model:value="formState.zbwj" />
      </a-form-item>
      <a-form-item ref="zbdw" label="中标单位" name="zbdw">
        <a-input v-model:value="formState.zbdw" />
      </a-form-item>
      <a-form-item ref="zbj" label="中标价（万元）" name="zbj">
        <a-input v-model:value="formState.zbj" />
      </a-form-item>
      <a-form-item ref="qdtime" label="合同签订日期" name="qdtime">
        <a-input v-model:value="formState.qdtime" />
      </a-form-item>
      <a-form-item ref="htfile" label="合同（扫描件）" name="htfile">
        <a-input v-model:value="formState.htfile" />
      </a-form-item>
      <a-form-item ref="fzr" label="负责人" name="fzr">
        <a-input v-model:value="formState.fzr" />
      </a-form-item>
      <a-form-item ref="fzrdh" label="负责人电话" name="fzrdh">
        <a-input v-model:value="formState.fzrdh" />
      </a-form-item>

    </a-form>
  </a-modal>
</template>
<script>
import {defineComponent, reactive, ref, watch} from "vue";
const previewFile = async file => {
  console.log('Your upload file:', file);
  // Your process logic. Here we just mock to the same file
  const res = await fetch('https://next.json-generator.com/api/json/get/4ytyBoLK8', {
    method: 'POST',
    body: file,
  });
  const {
    thumbnail,
  } = await res.json();
  return thumbnail;
};
const fileList = ref([]);
export default defineComponent({
  props: {
    visible: {
      type: Boolean,
    },
    record: {
      type: Object,
    }
  },
  emit: ["close"],
  setup(props, context) {
    const formRef = ref();

    console.log(props);
    const formState = reactive({
      sort: 0,
      enable: "true",
    });

    const formRules = {
      name: [{ required: true, message: "请输入岗位名称", trigger: "blur" }],
      code: [{ required: true, message: "请输入岗位编号", trigger: "blur" }],
    };
    watch(props,(props) => {
      console.log(props.record);
      // formState.name = props.record.name;
      // formState.type = props.record.type;
      // formState.zhaobdw = props.record.zhaobdw;
      // formState.dljg = props.record.dljg;
      // formState.zbnr = props.record.zbnr;
      // formState.zbwj = props.record.zbwj;
      // formState.zbdw = props.record.zbdw;
      // formState.zbj = props.record.zbj;
      // formState.qdtime = props.record.qdtime;
      // formState.htfile = props.record.htfile;
      // formState.fzr = props.record.fzr;
      // formState.fzrdh = props.record.fzrdh;
    })
    const saveKey = "save";

    const submit = (e) => {

    };

    const cancel = (e) => {
      context.emit("close", false);
    };

    const tokenKey = localStorage.getItem("token_key");
    const token = localStorage.getItem("token")

    const headers = {
      "Authorization": token,
      "Authorization-key": tokenKey
    };

    return {
      submit,
      cancel,
      headers,
      formRef,
      formState,
      formRules,

      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
    };
  },
});
</script>
